update emfl
	set emfl.MetaFieldOrder = l.n
from EntityMetaFieldLinks emfl
inner join (select l.EntityMetaFieldLinkId, ROW_NUMBER() over (PARTITION BY l.entitytypeparameter order by l.EntityMetaFieldLinkId) as n from EntityMetaFieldLinks l) l
	on l.EntityMetaFieldLinkId = emfl.EntityMetaFieldLinkId
go